package com.momo.web.controller.sysSetting;

import com.momo.common.common.JSONResult;
import com.momo.common.req.sysSetting.group.GroupRoleReq;
import com.momo.common.req.sysSetting.group.UserGroupReq;
import com.momo.common.req.sysSetting.group.VipUserReq;
import com.momo.common.req.sysSetting.user.SysUserReq;
import com.momo.service.sysSetting.VipService;
import com.momo.web.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * Created by MOMO on 2019/4/16.
 */
@RestController
@RequestMapping(value = "/platform/enterprise", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@Slf4j
public class VipController extends BaseController {
    @Autowired
    private VipService vipService;

    @PostMapping("/page/v1")
    public JSONResult page(@RequestBody UserGroupReq vipReq) {
        return vipService.vipPage(vipReq);
    }
    @PostMapping("/vipUserPage/v1")
    public JSONResult vipUserPage(@Validated(VipUserReq.Query.class)@RequestBody VipUserReq vipUserReq) {
        return vipService.vipUserPage(vipUserReq);
    }

    @PostMapping("/save/v1")
    public JSONResult save(@Validated(UserGroupReq.save.class) @RequestBody UserGroupReq vipReq) {
        return vipService.save(vipReq, this.redisUser());
    }
    @RequestMapping("/userAdd/v1")
    public JSONResult userAdd(@Validated(SysUserReq.Add.class) @RequestBody SysUserReq sysUserReq) {
        return vipService.userAdd(sysUserReq, this.redisUser());
    }
    @PostMapping("/modify/v1")
    public JSONResult modify(@Validated(UserGroupReq.Modify.class) @RequestBody UserGroupReq vipReq) {
        return vipService.modify(vipReq, this.redisUser());
    }

    @PostMapping("/uuid/v1")
    public JSONResult uuid(@Validated(UserGroupReq.Detail.class) @RequestBody UserGroupReq vipReq) {
        return vipService.uuid(vipReq);
    }

    @PostMapping("/status/v1")
    public JSONResult status(@Validated(UserGroupReq.Status.class) @RequestBody UserGroupReq vipReq) {
        return vipService.status(vipReq, this.redisUser());
    }

    @PostMapping("/rolePage/v1")
    public JSONResult rolePage(@Validated(GroupRoleReq.Query.class) @RequestBody GroupRoleReq groupRoleReq) {
        return vipService.rolePage(groupRoleReq);
    }

    @PostMapping("/groupRoleAdd/v1")
    public JSONResult groupRoleAdd(@Validated(GroupRoleReq.Add.class) @RequestBody GroupRoleReq groupRoleReq) {
        return vipService.groupRoleAdd(groupRoleReq, this.redisUser());
    }
}
